#ifndef _SCROLLVIEW_LULYUI_H_
#define _SCROLLVIEW_LULYUI_H_
#include <unordered_set>

#include "Layout.h"
#include "UIObject.h"
//垂直滚动视图
class ScrollView : public UIObject {
 public:
  enum class Alignment { Top, Bottom };

 private:
  //有一个垂直布局
  //他的HeightMode恒为FIT
  // Arrangement恒为VERTICAL
  Layout* layout;

  Alignment alignment;

  //这是与layout纵坐标最大的差值
  //用来表示滚动的范围
  //是一个0/正值
  int maxDeltaY = 0;
  int current_deltaY = 0;

  //每根在范围内按下手指的ID
  std::unordered_set<int> fingerIds;

  void event() override;
  void drawArea(const Rect& area) override;
  void init() override;

 public:
  ScrollView(std::string uiObjectId,
             ScrollView::Alignment alignment = ScrollView::Alignment::Top);

  //子对象是添加到layout里面的
  void addChild(UIObject* uiobject) override { layout->addChild(uiobject); }
  //重写setWidthMode
  void setWidthMode(UIObject::WHMode widthmode) override {
    UIObject::widthMode = widthMode;
    layout->setWidthMode(widthMode);  // layout的widthmode也可以改变
  }
  // setHeightMode和UIObject一样，不需要重写

  const int getMaxDeltaY() { return maxDeltaY; }
  const int getDeltaY() { return current_deltaY; }
};
#endif